home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / flex / flexs237.zoo / flexdef.h < prev    next >
C/C++ Source or Header  |  1993-03-05  |  30KB  |  894 lines

  1. /* flexdef - definitions file for flex */
  2.  
  3. /*-
  4.  * Copyright (c) 1990 The Regents of the University of California.
  5.  * All rights reserved.
  6.  *
  7.  * This code is derived from software contributed to Berkeley by
  8.  * Vern Paxson.
  9.  * 
  10.  * The United States Government has rights in this work pursuant
  11.  * to contract no. DE-AC03-76SF00098 between the United States
  12.  * Department of Energy and the University of California.
  13.  *
  14.  * Redistribution and use in source and binary forms are permitted provided
  15.  * that: (1) source distributions retain this entire copyright notice and
  16.  * comment, and (2) distributions including binaries display the following
  17.  * acknowledgement:  ``This product includes software developed by the
  18.  * University of California, Berkeley and its contributors'' in the
  19.  * documentation or other materials provided with the distribution and in
  20.  * all advertising materials mentioning features or use of this software.
  21.  * Neither the name of the University nor the names of its contributors may
  22.  * be used to endorse or promote products derived from this software without
  23.  * specific prior written permission.
  24.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  25.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  26.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27.  */
  28.  
  29. /* @(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/flexdef.h,v 2.10 90/08/03 14:09:52 vern Exp $ (LBL) */
  30.  
  31. #ifndef FILE
  32. #include <stdio.h>
  33. #endif
  34.  
  35. /* always be prepared to generate an 8-bit scanner */
  36. #define FLEX_8_BIT_CHARS
  37.  
  38. #ifdef FLEX_8_BIT_CHARS
  39. #define CSIZE 256
  40. #define Char unsigned char
  41. #else
  42. #define Char char
  43. #define CSIZE 128
  44. #endif
  45.  
  46. /* size of input alphabet - should be size of ASCII set */
  47. #ifndef DEFAULT_CSIZE
  48. #define DEFAULT_CSIZE 128
  49. #endif
  50.  
  51. #ifndef PROTO
  52. #ifdef __STDC__
  53. #define PROTO(proto) proto
  54. #else
  55. #define PROTO(proto) ()
  56. #endif
  57. #endif
  58.  
  59.  
  60. #ifdef USG
  61. #define SYS_V
  62. #endif
  63.  
  64. #ifdef SYS_V
  65. #include <string.h>
  66. #else
  67.  
  68. #include <strings.h>
  69. #ifdef lint
  70. char *sprintf(); /* keep lint happy */
  71. #endif
  72. #ifdef SCO_UNIX
  73. void *memset();
  74. #else
  75. #ifndef atarist
  76. char *memset();
  77. #endif
  78. #endif
  79. #endif
  80.  
  81. #ifdef AMIGA
  82. #define bzero(s, n) setmem((char *)(s), n, '\0')
  83. #ifndef abs
  84. #define abs(x) ((x) < 0 ? -(x) : (x))
  85. #endif
  86. #else
  87. #define bzero(s, n) (void) memset((char *)(s), '\0', n)
  88. #endif
  89.  
  90. #ifdef VMS
  91. #define unlink delete
  92. #define SHORT_FILE_NAMES
  93. #endif
  94.  
  95. #ifdef atarist
  96. #include <string.h>
  97. #include <stdlib.h>
  98. #include <unistd.h>
  99. #include <memory.h>
  100. #define SHORT_FILE_NAMES
  101. #endif
  102.  
  103. #ifdef __STDC__
  104.  
  105. #ifdef __GNUC__
  106. #include <stddef.h>
  107. void *malloc( size_t );
  108. void free( void* );
  109. #else
  110. #include <stdlib.h>
  111. #endif
  112.  
  113. #else    /* ! __STDC__ */
  114. char *malloc(), *realloc();
  115. #endif
  116.  
  117.  
  118. /* maximum line length we'll have to deal with */
  119. #define MAXLINE BUFSIZ
  120.  
  121. /* maximum size of file name */
  122. #ifndef FILENAME_MAX /* ansi compliant headers have this */
  123. #define FILENAMESIZE 1024
  124. #else
  125. #define FILENAMESIZE FILENAME_MAX
  126. #endif
  127.  
  128. #ifndef min
  129. #define min(x,y) ((x) < (y) ? (x) : (y))
  130. #endif
  131. #ifndef max
  132. #define max(x,y) ((x) > (y) ? (x) : (y))
  133. #endif
  134.  
  135. #ifdef MS_DOS
  136. #ifndef abs
  137. #define abs(x) ((x) < 0 ? -(x) : (x))
  138. #endif
  139. #define SHORT_FILE_NAMES
  140. #endif
  141.  
  142. #define true 1
  143. #define false 0
  144.  
  145.  
  146. #ifdef atarist
  147. #  define DEFAULT_SKELETON_FILE (getenv("FLEX_SKEL") ? getenv("FLEX_SKEL"): "flex.skel")
  148. #else
  149. #  ifndef DEFAULT_SKELETON_FILE
  150. #  define DEFAULT_SKELETON_FILE "flex.skel"
  151. #  endif
  152. #endif
  153.  
  154. /* special chk[] values marking the slots taking by end-of-buffer and action
  155.  * numbers
  156.  */
  157. #define EOB_POSITION -1
  158. #define ACTION_POSITION -2
  159.  
  160. /* number of data items per line for -f output */
  161. #define NUMDATAITEMS 10
  162.  
  163. /* number of lines of data in -f output before inserting a blank line for
  164.  * readability.
  165.  */
  166. #define NUMDATALINES 10
  167.  
  168. /* transition_struct_out() definitions */
  169. #define TRANS_STRUCT_PRINT_LENGTH 15
  170.  
  171. /* returns true if an nfa state has an epsilon out-transition slot
  172.  * that can be used.  This definition is currently not used.
  173.  */
  174. #define FREE_EPSILON(state) \
  175.     (transchar[state] == SYM_EPSILON && \
  176.      trans2[state] == NO_TRANSITION && \
  177.      finalst[state] != state)
  178.  
  179. /* returns true if an nfa state has an epsilon out-transition character
  180.  * and both slots are free
  181.  */
  182. #define SUPER_FREE_EPSILON(state) \
  183.     (transchar[state] == SYM_EPSILON && \
  184.      trans1[state] == NO_TRANSITION) \
  185.  
  186. /* maximum number of NFA states that can comprise a DFA state.  It's real
  187.  * big because if there's a lot of rules, the initial state will have a
  188.  * huge epsilon closure.
  189.  */
  190. #define INITIAL_MAX_DFA_SIZE 750
  191. #define MAX_DFA_SIZE_INCREMENT 750
  192.  
  193.  
  194. /* a note on the following masks.  They are used to mark accepting numbers
  195.  * as being special.  As such, they implicitly limit the number of accepting
  196.  * numbers (i.e., rules) because if there are too many rules the rule numbers
  197.  * will overload the mask bits.  Fortunately, this limit is \large/ (0x2000 ==
  198.  * 8192) so unlikely to actually cause any problems.  A check is made in
  199.  * new_rule() to ensure that this limit is not reached.
  200.  */
  201.  
  202. /* mask to mark a trailing context accepting number */
  203. #define YY_TRAILING_MASK 0x2000
  204.  
  205. /* mask to mark the accepting number of the "head" of a trailing context rule */
  206. #define YY_TRAILING_HEAD_MASK 0x4000
  207.  
  208. /* maximum number of rules, as outlined in the above note */
  209. #define MAX_RULE (YY_TRAILING_MASK - 1)
  210.  
  211.  
  212. /* NIL must be 0.  If not, its special meaning when making equivalence classes
  213.  * (it marks the representative of a given e.c.) will be unidentifiable
  214.  */
  215. #define NIL 0
  216.  
  217. #define JAM -1    /* to mark a missing DFA transition */
  218. #define NO_TRANSITION NIL
  219. #define UNIQUE -1    /* marks a symbol as an e.c. representative */
  220. #define INFINITY -1    /* for x{5,} constructions */
  221.  
  222. #define INITIAL_MAX_CCLS 100    /* max number of unique character classes */
  223. #define MAX_CCLS_INCREMENT 100
  224.  
  225. /* size of table holding members of character classes */
  226. #define INITIAL_MAX_CCL_TBL_SIZE 500
  227. #define MAX_CCL_TBL_SIZE_INCREMENT 250
  228.  
  229. #define INITIAL_MAX_RULES 100    /* default maximum number of rules */
  230. #define MAX_RULES_INCREMENT 100
  231.  
  232. #define INITIAL_MNS 2000    /* default maximum number of nfa states */
  233. #define MNS_INCREMENT 1000    /* amount to bump above by if it's not enough */
  234.  
  235. #define INITIAL_MAX_DFAS 1000    /* default maximum number of dfa states */
  236. #define MAX_DFAS_INCREMENT 1000
  237.  
  238. #define JAMSTATE -32766    /* marks a reference to the state that always jams */
  239.  
  240. /* enough so that if it's subtracted from an NFA state number, the result
  241.  * is guaranteed to be negative
  242.  */
  243. #define MARKER_DIFFERENCE 32000
  244. #define MAXIMUM_MNS 31999
  245.  
  246. /* maximum number of nxt/chk pairs for non-templates */
  247. #define INITIAL_MAX_XPAIRS 2000
  248. #define MAX_XPAIRS_INCREMENT 2000
  249.  
  250. /* maximum number of nxt/chk pairs needed for templates */
  251. #define INITIAL_MAX_TEMPLATE_XPAIRS 2500
  252. #define MAX_TEMPLATE_XPAIRS_INCREMENT 2500
  253.  
  254. #define SYM_EPSILON (CSIZE + 1)    /* to mark transitions on the symbol epsilon */
  255.  
  256. #define INITIAL_MAX_SCS 40    /* maximum number of start conditions */
  257. #define MAX_SCS_INCREMENT 40    /* amount to bump by if it's not enough */
  258.  
  259. #define ONE_STACK_SIZE 500    /* stack of states with only one out-transition */
  260. #define SAME_TRANS -1    /* transition is the same as "default" entry for state */
  261.  
  262. /* the following percentages are used to tune table compression:
  263.  
  264.  * the percentage the number of out-transitions a state must be of the
  265.  * number of equivalence classes in order to be considered for table
  266.  * compaction by using protos
  267.  */
  268. #define PROTO_SIZE_PERCENTAGE 15
  269.  
  270. /* the percentage the number of homogeneous out-transitions of a state
  271.  * must be of the number of total out-transitions of the state in order
  272.  * that the state's transition table is first compared with a potential 
  273.  * template of the most common out-transition instead of with the first
  274.  * proto in the proto queue
  275.  */
  276. #define CHECK_COM_PERCENTAGE 50
  277.  
  278. /* the percentage the number of differences between a state's transition
  279.  * table and the proto it was first compared with must be of the total
  280.  * number of out-transitions of the state in order to keep the first
  281.  * proto as a good match and not search any further
  282.  */
  283. #define FIRST_MATCH_DIFF_PERCENTAGE 10
  284.  
  285. /* the percentage the number of differences between a state's transition
  286.  * table and the most sim